﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TA.JSON;
using System.Collections;

namespace TA.Turbo.Controls
{
	public class ListJsonPropertyDefinition<T> : JsonPropertyDefinition<T>
		where T : class, IJsonCompatible, IList, new()
	{
		public ListJsonPropertyDefinition(string name, string shortName, T defaultValue)
			: base(name, shortName, defaultValue)
		{
		}
		public override void DeserializeValue(TControl control, JsonReader jr)
		{
			T t = this.GetValue(control);
			t.Clear();

			if (jr.TokenType != JsonToken.Null)
			{
				t.Deserialize(jr);
			}
		}
	}
}
